package com.tchepannou.limbe.gae.converter;

import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.datastore.*;
import com.tchepannou.util.converter.StringConverter;

public class StringConverterExt
    extends StringConverter
{
    //-- Converter overrides
    @Override
    public Object convert(Object value)
    {
        if (value instanceof Key)
        {
            return KeyFactory.keyToString((Key) value);
        }
        else if (value instanceof Text)
        {
            return ((Text)value).getValue();
        }
        else if (value instanceof Link)
        {
            return ((Link)value).getValue();
        }
        else if (value instanceof Email)
        {
            return ((Email)value).getEmail();
        }
        else if (value instanceof BlobKey)
        {
            return ((BlobKey)value).getKeyString();
        }
        else
        {
            return super.convert(value);
        }
    }
}
